From 8c5e32317b08c11ce6d74a2cf2e65a5a225122c1 Mon Sep 17 00:00:00 2001 From: "kaf24@scramble.cl.cam.ac.uk" Date: Fri, 6 Aug 2004 12:39:03 +0000 Subject: [PATCH] bitkeeper revision 1.1159.1.1 (41137be7CbsfIV_H_aLlq3moTPnDwA) Ensure binary patches are applied only to private VMAs. --- linux-2.6.7-xen-sparse/arch/xen/kernel/fixup.c | 16 ++++++++++++++++ 1 file changed, 16 insertions(+) diff --git a/linux-2.6.7-xen-sparse/arch/xen/kernel/fixup.c b/linux-2.6.7-xen-sparse/arch/xen/kernel/fixup.c index 55384af25f..61c5497f40 100644 --- a/linux-2.6.7-xen-sparse/arch/xen/kernel/fixup.c +++ b/linux-2.6.7-xen-sparse/arch/xen/kernel/fixup.c @@ -409,6 +409,22 @@ asmlinkage void do_fixup_4gb_segment(struct pt_regs *regs, long error_code) *(unsigned long *)&patch[1] = (fixup_buf_user + fe->fixup_idx) - (eip + 5); + /* + * Check that the page to be patched is part of a read-only VMA. This + * means that our patch will never erroneously get flushed to disc. + */ + if ( eip < PAGE_OFFSET ) /* don't need to check the fixmap area */ + { + /* [SMP] Need to the mmap_sem semaphore. */ + struct vm_area_struct *vma = find_vma(current->mm, eip); + if ( (vma == NULL) || (vma->vm_flags & VM_MAYSHARE) ) + { + DPRINTK("Cannot patch a shareable VMA."); + return; + } + } + + /* [SMP] Need to pause other threads while patching. */ pgd = pgd_offset(current->mm, eip); pmd = pmd_offset(pgd, eip); pte = pte_offset_kernel(pmd, eip); -- 2.30.2